home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / DTS.Utilities / Utilities.a < prev    next >
Encoding:
Text File  |  1991-01-30  |  8.7 KB  |  259 lines  |  [TEXT/MPS ]

  1.  
  2. ;=============================================================================================
  3.             GblA    &qMacApp
  4.             GblA    &qDebug
  5.             GblA    &qNames
  6.  
  7.         If &TYPE('qMacApp') = 'UNDEFINED' Then
  8. &qMacApp    SetA    0            ; we assume we’re MacAppless if qMacApp isn’t defined
  9.         Else
  10. &qMacApp    SetA    qMacApp
  11.         EndIf
  12.  
  13.         If &TYPE('qDebug') = 'UNDEFINED' Then
  14. &qDebug        SetA    0            ; default to qDebug off
  15.         Else
  16. &qDebug        SetA    qDebug
  17.         EndIf
  18.  
  19.         If &TYPE('qNames') = 'UNDEFINED' Then
  20. &qNames        SetA    &qDebug
  21.         Else
  22. &qNames        SetA    qNames
  23.         EndIf
  24.  
  25. * ================================================
  26. * ------   CONSTANTS DEFINITIONS SECTION  --------
  27. * ================================================
  28.  
  29. rAboutAlert        EQU    257                            ; about alert
  30. kUseCreatorString    EQU -1
  31. kUseRealAppName        EQU -2
  32.  
  33.  
  34. * ================================================
  35. * --------   MACRO DEFINITIONS SECTION  ----------
  36. * ================================================
  37.  
  38. * ------------- GENERATE A PASCAL “CASE” OR “IF” SEQUENCE -------------
  39. * The following macro is used to generate a branch based on an index value
  40. * in a D-register with a value from 0 to N.  The branch is through a table
  41. * of relative addresses also generated by this macro. The macro is called
  42. * in one of two forms as follows:
  43.  
  44. *  {Form #1}    Case#        (Dreg,Default),case0,case1,...caseN
  45. *  {Form #2}    Case#.<size>    (Dreg,IF),(cst0,case0),...,(cstN,caseN)
  46.  
  47. * In Form #1, the “Default” specifies a label for any omitted case labels not
  48. * specified explicitly. The “case0”, “case1”,...“caseN” are case labels
  49. * identifying the various cases to be processed.  A case label may be omitted,
  50. * in which case the “Default” is used. The “Default” may also be omitted, but
  51. * in that case all case labels must be specified. If there are fewer case labels
  52. * than there are cases, but there are N possible values for the case index, the
  53. * proper number of trailing commas must be supplied to generate the defaults.
  54.  
  55. * In Form #2, the default is specified as the word “IF”.  In this form the macro
  56. * generates a set of compares (CMPI’s) and branches (BEQ) for each specified
  57. * case (there is no implicit default).    Each case is a constant/label pair.
  58. * The constant is compared (CMPI.W) and an branch is done (BEQ) to the case if
  59. * the Dreg equals the constant.  A size may be specified for all the branches
  60. * as a <size> attribute to the Case# call itself.  This must either be an “S”
  61. * or “W” to generate BEQ.S’s or BEQ.W’s.  The default is for “S”.
  62.  
  63.         MACRO
  64.         Case#.&Size     &IdxDef
  65.         PRINT        Push,NoMDir         ; only list generated code
  66.         LCLA        &i                    ; index to macro parameters
  67.         LCLA        &n                    ; total number of macro parameters
  68.         LCLC        &Dreg,&Def            ; the Dreg and Default parameters
  69.         LCLC        &sz                 ; the <size> value
  70.  
  71. &Dreg    SETC        &IdxDef[1]            ; pick off 1st opnd of sublist
  72. &Def    SETC        &IdxDef[2]            ; pick off 2nd opnd of sublist
  73. &n        SETA        &Nbr(&Syslist)        ; done for efficiency
  74. &i        SETA        2                    ; cases start at 2nd parameter
  75.  
  76.     IF &UpCase(&Def) <> 'IF' THEN
  77.  
  78. .* Create the jump table and the index value
  79. * -----------------------------------------------
  80.         ADD         &Dreg,&Dreg
  81.         MOVE        Case&SysNdx(&Dreg),&Dreg
  82.         JMP         Case&SysNdx(&Dreg)
  83.  
  84. Case&SysNdx
  85.         WHILE &i <= &n DO                ; process each case label
  86.             IF &SysList[&i] <> '' THEN
  87.                 DC.W        &SysList[&i]-Case&SysNdx
  88.             ELSE
  89.                 DC.W        &Def-Case&SysNdx
  90.             ENDIF
  91.             &i: SETA &i+1                 ; count off parameter
  92.         ENDWHILE
  93.     ELSE                                ; process (Cst,lbl) pairs
  94.  
  95. .* Create a series of CMPI and BEQ instructions
  96. * -----------------------------------------------
  97.         &Sz: SETC &Default(&Size, 'S')     ; setup size attribute
  98.         WHILE &i <= &n DO                ; process each (Cst,lbl) pair
  99.             CMPI        #&SysList[&i,1],&Dreg
  100.             BEQ.&Sz     &SysList[&i,2]
  101.             &i: SETA &i+1                ; count off parameter
  102.         ENDWHILE
  103.     ENDIF
  104.  
  105.     PRINT    Pop                         ; restore original print status
  106.     ENDM
  107.  
  108.  
  109. * ------------- GENERATE DEBUGGER SYMBOL INFORMATION -------------
  110. * This Macro will generate information for the debugger to read and display
  111. * as its module name.  This aids in debugging Asm code while looking at it
  112. * in the debugger.  This macro can only work if called at the end of stack
  113. * frame.  The appearance of the Macro statement in the source code must occur
  114. * immediately after the final “JMP   (A0)” or “RTS” instruction following the UNLINK.
  115. * Spaces may be included in the name, but no quotes are allowed.
  116.  
  117. *  {Form #1}    DbgInfo.Old Name    ModName
  118. *  {Form #2}    DbgInfo.New Name    Really Long Module Name For MacsBug 6.0
  119. *  {Form #3}    DgbInfo    Name        Same as DbgInfo.New
  120.  
  121. * There are now two naming conventions used in MacsBug, Form #1 is the older MacsBug,
  122. * or TMON, and Form #2 is the newer MacsBug 6.0.  The older method would only
  123. * allow for a fixed length of eight characters.  If a shorter name is passed to
  124. * this Macro, it will extend the length to 8 chars with trailing spaces.
  125. * MacsBug 6.0 will now allow for a variable length C type string. This Macro will
  126. * create the proper DC statements and takes into account word alignment issues.
  127.  
  128.  
  129.         MACRO
  130.         DbgInfo.&Opt     &ModName#        ; the name to be used in the Debugger
  131.         PRINT        Push,NoMDir         ; Only list generated code
  132.         GBLA        &qNames                ; determines whether we want to do any of this
  133.         LCLC        &DbgName#            ; name to generate for MacsBug
  134.         LCLC        &DbgTemp            ; temporary name variable
  135.         LCLC        &New                ; variable used to test old vs. new
  136.         LCLC        &S                    ; variable used to save PRINT state
  137.  
  138.     IF &qNames THEN                ; do we want debugging info?
  139.         IF &ModName# ≠ '' THEN            ; did we get a module name?
  140.             &New: SETC &UpCase(&Opt)    ; make option all upper case
  141.             IF (&New = '') THEN            ; if user didn’t specify...
  142.                 &New: SETC 'NEW'        ; then default to new style
  143.             ENDIF
  144.             IF (&New = 'NEW') THEN        ; do we want new style?
  145.  
  146. .* Create the new MacsBug naming convention
  147. * -----------------------------------------------
  148.                 &DbgTemp: SETC    &ModName#                    ; generate new type symbols
  149.                 IF &Len(&ModName#) < 32 THEN                ; if module name < 32 chars
  150.                     IF &Len(&ModName#) // 2 = 0 THEN         ; add space if even so that...
  151.                         &DbgTemp: SETC &Concat(&ModName#,' ')     ; string length plus length byte...
  152.                     ENDIF                                    ; will align to word boundary
  153.                     &DbgName#: SETC &Concat(&Chr($80 + &Len(&ModName#)), &DbgTemp)
  154.                 ELSE                                        ; Length > 32 characters
  155.                     IF &Len(&ModName#) // 2 = 1 THEN         ; add space if length is odd
  156.                         &DbgTemp: SETC &Concat(&ModName#,' ')
  157.                     ENDIF
  158.                     &DbgName#: SETC &Concat(&Chr($80), &Chr(&Len(&ModName#)), &DbgTemp)
  159.                 ENDIF
  160.             ELSE                                            ; make it the older style
  161.  
  162. .* Create the older MacsBug naming convention
  163. * -----------------------------------------------
  164. ;                IF &Len(&ModName#) < 8 THEN                    ; if module name < 8 chars
  165.                     &DbgName#: SETC &Concat(&ModName#,'       ')    ; add at least 7 spaces
  166.                     &DbgName#: SETC &Concat(&Chr($80 + &ORD(&SubStr(&DbgName#,1,1))), &SubStr(&DbgName#,2,7))
  167. ;                ELSE                                        ; there are at least 8 chars
  168. ;                    &DbgName#: SETC &Concat(&Chr($80 + &ORD(&SubStr(&ModName#,1,1))), &SubStr(&ModName#,2,7))
  169. ;                ENDIF
  170.             ENDIF
  171.  
  172. .* Create the DC.B with the debugger name, and include the NULs if new MacsBug option
  173. * -----------------------------------------------
  174.             &S: SETC &Setting('STRING')    ; preserve STRING status
  175.             IF &S ≠ 'ASIS' THEN            ; only change it if not already ASIS
  176.                 STRING    ASIS
  177.                 DC.B      '&DbgName#'
  178.                 IF (&New = 'NEW') THEN
  179.                     DC.W        0        ; fake literal size for new MacsBug
  180.                 ENDIF
  181.                 STRING    &S
  182.             ELSE
  183.                 DC.B      '&DbgName#'
  184.                 IF (&New = 'NEW') THEN
  185.                     DC.W        0        ; fake literal size for new MacsBug
  186.                 ENDIF
  187.             ENDIF                        ; IF &S ≠ 'ASIS' THEN
  188.         ENDIF                            ; IF &ModName# ≠ '' THEN
  189.     ENDIF                                ; IF &qNames THEN
  190.  
  191.     PRINT    Pop                         ; restore original print status
  192.     ENDM
  193.  
  194.  
  195.  
  196. * ================================================
  197. * ----------------  RECORD TYPES  ----------------
  198. * ================================================
  199. * This section is declaring record structures.  These records are
  200. * templates.  No data is allocated at this point.  These are just
  201. * structures, similar to Pascal TYPEs.  They simply generate a list
  202. * of equate offsets.  Since none of these types are defined already
  203. * in the MPW AIncludes, we’ll need to define them.
  204.  
  205. * ------------- MOUSE POINT TYPE -------------
  206.  
  207. Point            RECORD    0
  208. v                DS.W    1
  209. h                DS.W    1
  210.                 ORG     v
  211. vh                DS.W    h
  212.                 ENDR
  213.  
  214. * ------------- RECTANGLE TYPE -------------
  215.  
  216. Rect            RECORD    0
  217. Top             DS.W    1
  218. Left            DS.W    1
  219. Bottom            DS.W    1
  220. Right            DS.W    1
  221.                 ORG     Top
  222. TopLeft            DS.L    1
  223. BotRight        DS.L    1
  224.                 ENDR
  225.  
  226. * ------------- BITMAP TYPE -------------
  227.  
  228. BitMap            RECORD    0
  229. baseAddr        DS.L    1
  230. rowBytes        DS.W    1
  231. bounds            DS.L    Rect
  232.                 ENDR
  233.  
  234. * ------------- EVENT RECORD TYPE -------------
  235.  
  236. EventRecord     RECORD    0
  237. What            DS.W    1
  238. Message         DS.L    1
  239. When            DS.L    1
  240. Where            DS.L    Point
  241. Modify            DS.W    1
  242.                 ENDR
  243.  
  244. * ------------- THE QUICKDRAW WORLD -------------
  245.  
  246. QuickGlobals    RECORD    0,DECREMENT
  247. GrafPort         DS.L    1
  248. White            DS.B    8
  249. Black            DS.B    8
  250. Gray            DS.B    8
  251. LtGray            DS.B    8
  252. DkGray            DS.B    8
  253. Arrow            DS.B    cursRec
  254. ScreenBits        DS.B    BitMap
  255. RandSeed        DS.L    1
  256.                 ORG     -GrafSize
  257.                 ENDR
  258.  
  259.